import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';

import { BaseResponse } from '@server/basic-dto';

export declare type GetFileDetailType = Partial<{
  code: number;
  message: string;
  mime: string;
  buffer: Buffer;
}>;

export class UploadFileDto {
  filename: string;
  originalname: string;
  encoding: string;
  mimetype: string;
  buffer: Buffer;
  size: number;
}

export class UploadFileData {
  @ApiProperty({
    description: '文件的访问地址',
    type: String,
  })
  url: string;
}

export class UploadFileResponse extends BaseResponse {
  @ApiProperty({
    description: '长传成功的返回',
    type: UploadFileData,
  })
  @Type(() => UploadFileData)
  data?: UploadFileData;
}
